﻿
using Microsoft.EntityFrameworkCore;
using yiwei.Repository.Entity;
using yiwei.Repository.EntityConfig;

namespace yiwei.Repository
{
    public class YiWeiDBContext:DbContext
    {
        //构造函数可以简单地接受 DbContextOptions
        public YiWeiDBContext(DbContextOptions<YiWeiDBContext> options)
       : base(options)
        { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.ApplyConfiguration(new ModuleMap());
            modelBuilder.ApplyConfiguration(new ModuleElementMap());
            modelBuilder.ApplyConfiguration(new RelevanceMap());
            modelBuilder.ApplyConfiguration<Role>(new RoleMap());
            modelBuilder.ApplyConfiguration<User>(new UserMap());
            base.OnModelCreating(modelBuilder);
        }

        public virtual DbSet<Module> Modules { get; set; }
        public virtual DbSet<ModuleElement> ModuleElements { get; set; }
        public virtual DbSet<Relevance> Relevances { get; set; }
        public virtual DbSet<Role> Roles { get; set; }
        public virtual DbSet<User> Users { get; set; }


    }
}
